//
//  PanelDetailViewController.m
//  ProjectOneDemo
//
//  Created by dllo on 16/5/18.
//  Copyright © 2016年 wjg. All rights reserved.
//

#import "PanelDetailViewController.h"
#import "AccountBookStyleCell.h"
#import "PanelDetailCell.h"
#import "Common.h"
@interface PanelDetailViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSArray *picArr;
@property (nonatomic, strong)NSArray *nameArr;
@property (nonatomic, strong) UIButton *backButton;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation PanelDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createView];
}

- (void)createView {
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    
    self.lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 40, MAIN_WIDTH, 1)];
    [self.navigationController.navigationBar addSubview:_lineView];
    self.lineView.backgroundColor = LIGHT_GRAY;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.backButton = ({
        BaseButton *tempButton = [BaseButton buttonWithType:UIButtonTypeCustom];
        tempButton.frame = CGRectMake(5 / 414.0 * MAIN_WIDTH, 8, 30 / 414.0 * MAIN_WIDTH, 25 / 414.0 * MAIN_WIDTH);
        [self.navigationController.navigationBar addSubview:tempButton];
        [tempButton setImage:[UIImage imageNamed:@"fanhui.png"] forState:UIControlStateNormal];
        [tempButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        tempButton;
    });
    
    
    self.tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.rowHeight = 100;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    
    
    [self.tableView registerClass:[PanelDetailCell class] forCellReuseIdentifier:NSStringFromClass([PanelDetailCell class])];
    
    self.picArr = @[@"jiandian.jpg", @"bgImage5.jpg", @"zhuangxiu.jpg", @"jiehun.jpg", @"bookTemplateBg_5@3x.png", @"baobao.jpg"];
    
    self.nameArr = @[@"经典面板", @"旅游面板", @"装修面板", @"结婚面板", @"汽车面板", @"宝宝面板"];
    

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 70;
}




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PanelDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PanelDetailCell class]) forIndexPath:indexPath];
    cell.picImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", self.picArr[indexPath.row]]];
    cell.nameLabel.text = self.nameArr[indexPath.row];
    return cell;
    
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.delegate sendThemeIndex:indexPath.row];
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];

    
}

- (void)backButtonAction:(UIButton *)button {
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
